package com.weifangfirecontrolformal.weifangfirecontrolformal.web.web.maintenancesystem.basisinfo;

import cn.hutool.json.JSONObject;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseController;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.Action;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.At;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.maintenancesystem.basisinfo.CustomerService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * 直属客户控制器
 */
@Action
@RequestMapping(value = "customer")
public class CustomerController extends BaseController {

    @Resource
    private CustomerService customerService;

    @At(value = "customerPageList", method = RequestMethod.GET, param = {"page", "limit"})
    public RespEntity customerPageList(@RequestBody(required = false) JSONObject jsonParam) {
        return customerService.customerPageList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 直属客户新增
     * @Date Created in 11:29 2020/12/28
     * @Param [jsonParam]
     */

    @At(value = "add", method = RequestMethod.POST)
    public RespEntity add(@RequestBody(required = false) JSONObject jsonParam) {
        return customerService.add(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 直属客户更新
     * @Date Created in 11:29 2020/12/28
     * @Param [jsonParam]
     */

    @At(value = "update", method = RequestMethod.POST)
    public RespEntity update(@RequestBody(required = false) JSONObject jsonParam) {
        return customerService.update(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 直属客户详情
     * @Date Created in 11:30 2020/12/28
     * @Param [jsonParam]
     */

    @At(value = "detail", method = RequestMethod.GET)
    public RespEntity detail(@RequestBody(required = false) JSONObject jsonParam) {
        return customerService.detail(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 直属客户删除
     * @Date Created in 11:30 2020/12/28
     * @Param [jsonParam]
     */

    @At(value = "delete", method = RequestMethod.POST)
    public RespEntity delete(@RequestBody(required = false) JSONObject jsonParam) {
        return customerService.delete(jsonParam);
    }
}
